﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestRequestResponseMessages;
using PServiceBus.MessageProxy.Interface;
using PServiceBus.MessageProxy;
using PServiceBus.Transports;

namespace TestRequestResponseServer {

    public class RequestResponseServer : IESBMessage<Request, Response> {

        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "1111")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        public Response Handle(Request msg) {
            var response = new Response();
            response.Success = true;
            response.Message = "Processed successfully";
            Console.WriteLine("Received Request with ID[{0}] and Data = {1}",
                msg.ESBCorrelationID, msg.Data);
            return response;
        }

    }

    class Program {
        static void Main(string[] args) {
            ProxyService.Start();

            Console.WriteLine("Waiting for request.... Press enter to exit");
            Console.ReadLine();

            ProxyService.Shutdown();
        }
    }
}
